package com.taobao.mrs.zookeeper.test;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer extends Thread{

	int port;
	ServerSocket server;
	public SocketServer(int port){
		this.port=port;
		try{
			System.out.println("open port:"+port);
			 server = new ServerSocket(port); 
			  } catch (IOException e) {
			    System.out.println("Could not listen on port");
			    System.exit(-1);
			  }
	}
	
	public void run(){
		while(true){
		try{
		   Socket client = server.accept();
		   System.out.println("accept=="+client.getPort());
		  } catch (IOException e) {
		    System.out.println("Accept failed: 4321");
		    System.exit(-1);
		  }
		}
			  
	}
}